<%@page import="com.muk.meis.util.StringUtil"%>
<%@page import="com.muk.meis.model.bean.OpecSchool"%>
<%@page import="com.muk.meis.model.service.OpecSchoolService"%>
<%@page import="java.io.File"%>
<%@page import="com.muk.meis.util.FileUtil"%>
<%@page import="com.muk.meis.model.service.AnswerService"%>
<%@page import="com.muk.meis.model.service.QuestionService"%>
<%@page import="com.muk.meis.model.bean.Question"%>
<%@page import="com.muk.meis.model.service.UserService"%>
<%@page import="com.muk.meis.MEISConstance"%>
<%@page import="com.muk.meis.model.bean.UserProfile"%>
<%@page import="java.util.Locale"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.muk.meis.model.bean.SchoolNew"%>
<%@page import="java.util.List"%>
<%@page import="com.muk.meis.model.service.SchoolNewsService"%>
<%@page import="com.muk.meis.model.service.SchoolService"%>
<%@page import="com.muk.meis.model.bean.SchoolInfo"%>
<%@page import="com.muk.meis.model.service.SchoolInfoService"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MEIS</title>
<link href="layout.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="../js/flot/excanvas.min.js"></script><![endif]-->
<link href="../css/dropdown/themes/default/helper.css" media="screen" rel="stylesheet" type="text/css" />
<!-- Beginning of compulsory code below -->

<link href="../css/dropdown/dropdown.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../css/dropdown/themes/default/default.css" media="screen" rel="stylesheet" type="text/css" />
<link type="text/css" href="../css/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" />
<link type="text/css" href="../css/meis.css" rel="stylesheet" />
<!--[if lt IE 7]>
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript" src="js/jquery/jquery.dropdown.js"></script>
<![endif]-->

<!-- / END -->
<script language="javascript" type="text/javascript"
	src="../js/flot/jquery-1.6.2.js"></script>
<script language="javascript" type="text/javascript"
	src="../js/flot/jquery.flot.js"></script>
<script type="text/javascript" src="../js/jquery/jquery-ui-1.8.16.custom.min.js"></script>		

<script type="text/javascript">
	$(function(){
		// Tabs
		$('#tabs').tabs();
	});
</script>

<style type="text/css">
.mesi_header_m {
	color: #F00;
}

.ui-widget-content {
  font-size:95%;
}

</style>
		
</head>
<body>
<%
  String perCode = request.getParameter("percode");
  String editMode = request.getParameter("editmode");
  String editopec = request.getParameter("editopec");
  SchoolInfoService service = new SchoolInfoService();
  UserService userService = new UserService();
  SchoolInfo schoolInfo = service.findById(perCode);  
  boolean isEdit = false;
  boolean passLogin = false;
  boolean isEditOPEC = false;
  UserProfile userPassLogin = (UserProfile)session.getAttribute(MEISConstance.USER_PASS_LOGIN);
  if((editMode != null) &&
     (userPassLogin != null) &&
     (MEISConstance.ADMIN_ROLE.equals(userPassLogin.getRole())||
	 perCode.equals(userPassLogin.getPercodeCode()))){
	  isEdit = true;	  
  }
  if((userPassLogin != null) &&
     (MEISConstance.ADMIN_ROLE.equals(userPassLogin.getRole())||perCode.equals(userPassLogin.getPercodeCode()))){
	  passLogin = true;
  }
  if((editopec != null) &&
	 (userPassLogin != null) &&
	 (MEISConstance.ADMIN_ROLE.equals(userPassLogin.getRole())||
	  perCode.equals(userPassLogin.getPercodeCode()))){
	   isEditOPEC = true;	  
  }  
%>
<% if(userPassLogin != null) { %>
      <jsp:include page="../menu_admin.jsp"></jsp:include>
<%} else { %>
       <div style="position:relative;background-image: url('../image/header_background.gif'); width:1000px; height:140px; color: #333;font-size:25px;">
          <div style="width:800px; padding-left:50px;padding-top:50px;"><span class="mesi_header_m">M</span>ukdahan education information system</div>
          <div style="position:relative; padding-left:50px; font-size:20px;">
               <span>โรงเรียน</span>
               <span style="padding-left: 1px;"><%=SchoolService.getSchoolNameByPerCode(perCode)%></span>
         </div>
       </div>
<%} %>

<div style="position:relative;padding-top:50px;padding-left:10px;">
	<div style="position:relative;">
	    
		<div id="tabs" style="width: 1050px;">
			<ul>
				<li><a href="#tabs-1">DashBoard</a></li>
				<li><a href="#tabs-2">ข่าวประชาสัมพันธ์</a></li>
				<li><a href="#tabs-3">ไฟล์</a></li>
				<li><a href="#tabs-4">เกณฑ์มาตรฐานสพฐ</a></li>
				<li><a href="#tabs-5">ถามตอบ</a></li>
				<li><a href="#tabs-6">ข้อมูลโรงเรียน</a></li>
			</ul>
			
			<div id="tabs-1">
			<table>
				<tr>
					<td>
					<%
					SchoolService schoolService = new SchoolService();
					String xmlSchoolReport = schoolService.getXMLSchoolReport(perCode);
					String xmlDistrict = schoolService.getXMLDistrict(perCode);
					String xmlAll = schoolService.getXMLALLMuk();
					%>
						<div title="กราฟ">	
						<!-- amcharts script-->
						<!-- swf object (version 2.2) is used to detect if flash is installed and include swf in the page -->
						<script type="text/javascript" src="../amcharts/flash/swfobject.js"></script>
						
						<!-- chart is placed in this div. if you have more than one chart on a page, give unique id for each div -->
						<div id="chart1" style="visibility: hidden;"></div>
						    <script type="text/javascript">
						    
						           var params = {
						               bgcolor:"#FFFFFF"
						               };
						
							    var flashVars = {
							        path: "../amcharts/flash/",
							        //chart_settings: encodeURIComponent("<settings><background><alpha>100</alpha><border_alpha>20</border_alpha></background><legend><enabled>0</enabled><align>center</align></legend><pie><y>50%</y><inner_radius>30</inner_radius></pie><animation><start_time>2</start_time><start_effect>strong</start_effect><pull_out_time>1.5</pull_out_time></animation><data_labels><show>{title}: {value}</show><max_width>140</max_width></data_labels></settings>"),
							        //settings_file: "../report/settings_barchart.xml",
							        chart_settings: encodeURIComponent("<settings><background><alpha>100</alpha><border_alpha>20</border_alpha></background><grid><category><dashed>1</dashed></category><value><dashed>1</dashed></value></grid><axes><category><width>1</width><color>E7E7E7</color></category><value><width>1</width><color>E7E7E7</color></value></axes><values><value><min>0</min></value></values><depth>15</depth><column><width>85</width><balloon_text>{title}: {value}</balloon_text><grow_time>1</grow_time><grow_effect>regular</grow_effect></column><graphs><graph gid='0'><title>ชาย</title><color>ADD981</color></graph><graph gid='1'><title>หญิง</title><color>7F8DA9</color></graph></graphs><labels><label lid='0'><text><![CDATA[<b>ข้อมูลนักเรียน</b>]]></text><y>18</y><text_color>000000</text_color><text_size>13</text_size><align>center</align></label></labels></settings>"),
						            chart_data: encodeURIComponent("<%=xmlSchoolReport%>"),
							        chart_id:"chart1"
								};
						
						    	swfobject.embedSWF("../amcharts/flash/amcolumn.swf", "chart1", "500", "300", "8.0.0", "../amcharts/flash/expressInstall.swf", flashVars, params);
						
						       </script>
						</div>					
					</td>
					<td>
				        <div id="chart2" style="width:500px; height:300px; background-color:#FFFFFF"></div>
				        <%
				        OpecSchoolService opecSchoolService = new OpecSchoolService();
				        String opecGraph = opecSchoolService.getDataGraph(perCode);
				        %>
				        <script type="text/javascript">
				        
				            var params = 
				            {
				                bgcolor:"#FFFFFF"
				            };
				            
				            var flashVars = 
				            {
				                path: "../amcharts/flash/",
				            
				                /* in most cases settings and data are loaded from files, but, as this require
				                 all the files to be upladed to web server, we use inline data and settings here.*/
				                 
				                // settings_file: "../sampleData/radar_settings.xml",
				                // data_file: "../sampleData/radar_data.xml"
				                
				                /*chart_data: "1;20\n2;15\n3;12\n4;18\n5;11\n6;19\n7;25\n8;20\n9;15\n10;12\n11;18\n12;11\n13;19\n14;25\n15;12\n16;20\n17;15\n18;17",*/
				                //chart_settings: "<settings><data_type>csv</data_type><grid><approx_count>5</approx_count></grid><values><skip_first>0</skip_first><min>0</min></values><balloon><show>{title} {axis} = {value} คะแนน</show></balloon><legend><align>center</align></legend><graphs><graph gid='0'><title>มาตรฐานที่</title><color>FFCC00</color><line_width>2</line_width><bullet>round</bullet></graph></graphs></settings>"
				        	    //chart_data: encodeURIComponent("<chart><axes><axis xid='0'>Sales</axis><axis xid='1'>Development</axis><axis xid='2'>Marketing</axis><axis xid='3'>Customer Support</axis><axis xid='4'>Administration</axis><axis xid='5'>Information technology</axis></axes><graphs><graph gid='0'><value xid='0'>20</value><value xid='1'>15</value><value xid='2'>12</value><value xid='3'>18</value><value xid='4'>11</value><value xid='5'>19</value></graph><graph gid='1'><value xid='0'>18</value><value xid='1'>13</value><value xid='2'>16</value><value xid='3'>15</value><value xid='4'>5</value><value xid='5'>13</value></graph></graphs></chart>"),
				        	    chart_data: encodeURIComponent("<%=opecGraph%>"),
				            	chart_settings: encodeURIComponent("<settings><background><alpha>100</alpha><border_alpha>20</border_alpha></background><balloon><show>{title}: ${value} mln.</show></balloon><legend><align>center</align></legend><graphs><graph gid='0'><title>มาตร</title><color>FFCC00</color><line_width>2</line_width><bullet>round</bullet></graph><graph gid='1'><title>Alocated budget</title><color>999999</color><line_width>2</line_width><bullet>round</bullet></graph></graphs><labels><label lid='0'><text><![CDATA[<b>ข้อมูล สพฐ</b>]]></text><y>23</y><text_size>12</text_size><align>center</align></label></labels></settings>")
				        	
				            };
				            // change 8 to 80 to test javascript version
				            if (swfobject.hasFlashPlayerVersion("8"))
				            {
				                swfobject.embedSWF("../amcharts/flash/amradar.swf", "chart2", "500", "300", "8.0.0", "../amcharts/flash/expressInstall.swf", flashVars, params);
				            }
				            else
				            {
				                var amFallback = new AmCharts.AmFallback();
				                // amFallback.settingsFile = flashVars.settings_file;  		// doesn't support multiple settings files or additional_chart_settins as flash does
				                // amFallback.dataFile = flashVars.data_file;
				                amFallback.chartSettings = flashVars.chart_settings;
				                amFallback.pathToImages = "../amcharts/javascript/images/";
				                amFallback.chartData = flashVars.chart_data;
				                amFallback.type = "radar";
				                amFallback.write("chart2");
				            }
				        
				        </script>
					    </div>					
					</td>					
				</tr>
				<tr>
					<td>
									<div title="กราฟ">	
										<!-- amcharts script-->
										<!-- swf object (version 2.2) is used to detect if flash is installed and include swf in the page -->
										<script type="text/javascript" src="../amcharts/flash/swfobject.js"></script>
								
										<!-- chart is placed in this div. if you have more than one chart on a page, give unique id for each div -->
										<div id="chart3" style="visibility: hidden;"></div>
										    <script type="text/javascript">
										    
									            var params = {
									                bgcolor:"#FFFFFF"
									                };
									
											    var flashVars = {
											        path: "../amcharts/flash/",
											        //chart_settings: encodeURIComponent("<settings><background><alpha>100</alpha><border_alpha>20</border_alpha></background><legend><enabled>0</enabled><align>center</align></legend><pie><y>50%</y><inner_radius>30</inner_radius></pie><animation><start_time>2</start_time><start_effect>strong</start_effect><pull_out_time>1.5</pull_out_time></animation><data_labels><show>{title}: {value}</show><max_width>140</max_width></data_labels></settings>"),
											        //settings_file: "test/settings.xml",
											        chart_settings: encodeURIComponent("<settings><background><alpha>100</alpha><border_alpha>20</border_alpha></background><grid><category><dashed>1</dashed></category><value><dashed>1</dashed></value></grid><axes><category><width>1</width><color>E7E7E7</color></category><value><width>1</width><color>E7E7E7</color></value></axes><values><value><min>0</min></value></values><depth>15</depth><column><width>85</width><balloon_text>{title}: {value}</balloon_text><grow_time>1</grow_time><grow_effect>regular</grow_effect></column><graphs><graph gid='0'><title>ชาย</title><color>ADD981</color></graph><graph gid='1'><title>หญิง</title><color>7F8DA9</color></graph></graphs><labels><label lid='0'><text><![CDATA[<b>ผู้เรียนตามอำเภอ</b>]]></text><y>18</y><text_color>000000</text_color><text_size>13</text_size><align>center</align></label></labels></settings>"),
											        chart_data: encodeURIComponent("<%=xmlDistrict%>"),
											        chart_id:"chart3"
												};
									
										    	swfobject.embedSWF("../amcharts/flash/amcolumn.swf", "chart3", "500", "300", "8.0.0", "../amcharts/flash/expressInstall.swf", flashVars, params);
										    	flashMovie.setSettings("ผู้เรียนตามอำเภอ", true);
									        </script>
									 </div>					
					</td>
					<td>
									<div title="กราฟ">	
										<!-- amcharts script-->
										<!-- swf object (version 2.2) is used to detect if flash is installed and include swf in the page -->
										<script type="text/javascript" src="../amcharts/flash/swfobject.js"></script>
								
										<!-- chart is placed in this div. if you have more than one chart on a page, give unique id for each div -->
										<div id="chart4" style="visibility: hidden;"></div>
										    <script type="text/javascript">
										    
									            var params = {
									                bgcolor:"#FFFFFF"
									                };
									
											    var flashVars = {
											        path: "../amcharts/flash/",
											        chart_settings: encodeURIComponent("<settings><background><alpha>100</alpha><border_alpha>20</border_alpha></background><grid><category><dashed>1</dashed></category><value><dashed>1</dashed></value></grid><axes><category><width>1</width><color>E7E7E7</color></category><value><width>1</width><color>E7E7E7</color></value></axes><values><value><min>0</min></value></values><depth>15</depth><column><width>85</width><balloon_text>{title}: {value}</balloon_text><grow_time>1</grow_time><grow_effect>regular</grow_effect></column><graphs><graph gid='0'><title>ชาย</title><color>ADD981</color></graph><graph gid='1'><title>หญิง</title><color>7F8DA9</color></graph></graphs><labels><label lid='0'><text><![CDATA[<b>ผู้เรียนตามจังหวัด</b>]]></text><y>18</y><text_color>000000</text_color><text_size>13</text_size><align>center</align></label></labels></settings>"),
											        //settings_file: "test/settings.xml",
											        //settings_file: "../report/settings_barchart.xml",
											        chart_data: encodeURIComponent("<%=xmlAll%>"),
											        chart_id:"chart4"
												};
									
										    	swfobject.embedSWF("../amcharts/flash/amcolumn.swf", "chart4", "500", "300", "8.0.0", "../amcharts/flash/expressInstall.swf", flashVars, params);
									 
									        </script>
									 </div>						
					</td>					
				</tr>
			</table>


									 				
			</div>
			
			<div id="tabs-2">
				<% if(passLogin) { %>
				   <div align="right" style="padding-bottom: 7px;">
				      <a href="<%="create.jsp?percode="+perCode%>">เพิ่มข่าว</a>
				   </div>
				<%} %>			
			    <table>	    	
			    	<%
			    	SchoolNewsService newsService = new SchoolNewsService();
					SimpleDateFormat sdf = new SimpleDateFormat("dd MMMM yyyy", new Locale("th", "TH"));
			    	
			    	List<SchoolNew> lst = newsService.listByPerCode(perCode);
			    	for(SchoolNew news : lst){	    	
			    	%>
				    	<tr>
					    	<td>
						    	<a href="<%="edit.jsp?newsid="+news.getNewsId()+"&percode="+perCode%>">
						    		<%=news.getTitle()%>
						         </a>
					    		โดย  <span style="padding-left:5px;"><%=userService.getUserDetail(news.getUserId()).getUserName()%> 
					    		(<%=sdf.format(news.getCreateDate())%>)
					    	</td>
				    	</tr>
			    	<%} %>
			    </table>			
			</div>
			
			<div id="tabs-3">
					<form action="<%=request.getContextPath()+"/UploadFileController"%>" enctype="multipart/form-data" method="post">
					      <input type="hidden" name="percode" value="<%=perCode%>"/>
                          <div style="position: relative;padding-left: 250px;padding-top: 50px;">
	                          <div><input type="file" name="uploadFile" /></div>
			                  <div style="position: relative;padding-left: 45px;padding-top: 5px;"><input type="submit" style="width: 70px;height: 30px;padding-top: 5px;" value="Upload"/></div>
		                  </div>
		                  <div style="position: relative;padding-top: 20px;">
		                  	<%
		                  	String path = getServletContext().getRealPath("/") + "data" + File.separator+perCode;
		                  	String[] listFileName = FileUtil.getListFileName(path);
		                  	if(listFileName.length > 0) {
		                  	%>
		                  	  <div class="ui-widget-header" style="width: auto;height: 35px;">
		                  	      <span style="position: relative;font-size: 18px;padding-left: 10px;top: 4px;">
		                  	                          รายการไฟล์ที่สามารถ download
		                  	      </span>
		                  	  </div>
		                  	  
		                  	<table style="position: relative;padding-left: 30px;padding-top: 20px;">
		                  	<%
		                  	}
		                  	for(String fileName:listFileName) {
		                  	%>
			                  	<tr>
			                  		<td><a href="<%=request.getContextPath()+"/data/"+perCode+"/"+fileName%>"><%=fileName%></a></td>
			                  	</tr>
		                  	<%} %>
		                  	</table>
		                  </div>
	               </form>
	        </div>
	          
	        <div id="tabs-4">
	        	<div>
        <!-- saved from url=(0013)about:internet -->
        <!-- amcharts script-->
        <!-- swf object (version 2.2) is used to detect if flash is installed and include swf in the page -->
        <script type="text/javascript" src="../amcharts/flash/swfobject.js"></script>
        
        <!-- following scripts required for JavaScript version. The order is important! -->
        <script type="text/javascript" src="../amcharts/javascript/amcharts.js"></script>
        <script type="text/javascript" src="../amcharts/javascript/amfallback.js"></script>
        <script type="text/javascript" src="../amcharts/javascript/raphael.js"></script>
        
        <!-- chart is placed in this div. if you have more than one chart on a page, give unique id for each div -->
        <div id="chartdiv" style="width:600px; height:400px; background-color:#FFFFFF"></div>
        <%
        //OpecSchoolService opecSchoolService = new OpecSchoolService();
        //String opecGraph = opecSchoolService.getDataGraph(perCode);
        %>
        <script type="text/javascript">
        
            var params = 
            {
                bgcolor:"#FFFFFF"
            };
            
            var flashVars = 
            {
                path: "../amcharts/flash/",
            
                /* in most cases settings and data are loaded from files, but, as this require
                 all the files to be upladed to web server, we use inline data and settings here.*/
                 
                // settings_file: "../sampleData/radar_settings.xml",
                // data_file: "../sampleData/radar_data.xml"
                
                /*chart_data: <%=opecSchoolService.getDataGraph(perCode)+","%>*/
                /*chart_data: "1;20\n2;15\n3;12\n4;18\n5;11\n6;19\n7;25\n8;20\n9;15\n10;12\n11;18\n12;11\n13;19\n14;25\n15;12\n16;20\n17;15\n18;17",*/
                //chart_settings: "<settings><data_type>csv</data_type><grid><approx_count>5</approx_count></grid><values><skip_first>0</skip_first><min>0</min></values><balloon><show>{title} {axis} = {value} คะแนน</show></balloon><legend><align>center</align></legend><graphs><graph gid='0'><title>มาตรฐานที่</title><color>FFCC00</color><line_width>2</line_width><bullet>round</bullet></graph></graphs></settings>"
        	    //chart_data: encodeURIComponent("<chart><axes><axis xid='0'>Sales</axis><axis xid='1'>Development</axis><axis xid='2'>Marketing</axis><axis xid='3'>Customer Support</axis><axis xid='4'>Administration</axis><axis xid='5'>Information technology</axis></axes><graphs><graph gid='0'><value xid='0'>20</value><value xid='1'>15</value><value xid='2'>12</value><value xid='3'>18</value><value xid='4'>11</value><value xid='5'>19</value></graph><graph gid='1'><value xid='0'>18</value><value xid='1'>13</value><value xid='2'>16</value><value xid='3'>15</value><value xid='4'>5</value><value xid='5'>13</value></graph></graphs></chart>"),
        	    chart_data: encodeURIComponent("<%=opecGraph%>"),
            	chart_settings: encodeURIComponent("<settings><background><alpha>100</alpha><border_alpha>20</border_alpha></background><balloon><show>{title}: ${value} mln.</show></balloon><legend><align>center</align></legend><graphs><graph gid='0'><title>มาตร</title><color>FFCC00</color><line_width>2</line_width><bullet>round</bullet></graph><graph gid='1'><title>Alocated budget</title><color>999999</color><line_width>2</line_width><bullet>round</bullet></graph></graphs><labels><label lid='0'><text><![CDATA[<b>ข้อมูล สพฐ</b>]]></text><y>23</y><text_size>12</text_size><align>center</align></label></labels></settings>")
        	
            };
            // change 8 to 80 to test javascript version
            if (swfobject.hasFlashPlayerVersion("8"))
            {
                swfobject.embedSWF("../amcharts/flash/amradar.swf", "chartdiv", "600", "400", "8.0.0", "../amcharts/flash/expressInstall.swf", flashVars, params);
            }
            else
            {
                var amFallback = new AmCharts.AmFallback();
                // amFallback.settingsFile = flashVars.settings_file;  		// doesn't support multiple settings files or additional_chart_settins as flash does
                // amFallback.dataFile = flashVars.data_file;
                amFallback.chartSettings = flashVars.chart_settings;
                amFallback.pathToImages = "../amcharts/javascript/images/";
                amFallback.chartData = flashVars.chart_data;
                amFallback.type = "radar";
                amFallback.write("chartdiv");
            }
        
        </script>
	        	</div>
	        	
	        	<form action="<%=request.getContextPath()+"/OPECController/update"%>">
	        	<input type="hidden" name="percode" value="<%=perCode%>"/>
		        	<div>
		        		<div class="ui-widget-header">ข้อมูล สพฐ</div>	        		
		        		<div style="position: relative;padding-top: 20px;">
	
						<%if(passLogin && !isEditOPEC) { %>	
						  <div align="right">
		        			<a href="<%="listnews.jsp?percode="+perCode+"&editopec=edit#tabs-4"%>">แก้ไขข้อมูล</a>
		        		  </div>		  
						<%} else if(isEditOPEC) {%>
						  <div align="right"><input type="submit" name="save_opec" value="บันทึก"/></div>
						<%} %>	        		
			        		<table>
			        		<%		        		
			        		List<Object[]> opecList = opecSchoolService.getByPercode(perCode);
			        		int couter = 1;
			        		for(Object [] obj: opecList){
			        		%>
			        			<tr>
			        				<td>
			        				    <span><%="มาตรฐานที่  "+couter+" "+obj[0]%></span>
			        				</td>
			        			</tr>
			        			<tr>
			        				<td style="padding-left: 5px;">
			        				       คะแนน
			        				  <%if(!isEditOPEC) { %>	
			        				  	<span style="padding-left: 5px;"><%=obj[1]%></span>
			        				  <%} else if(isEditOPEC) {%>
			        				  	<input type="text" name="<%="opec_value"+obj[2]%>" value="<%=obj[1]%>"/>
			        				  <%}%>
			        				</td>
			        			</tr>
			        		<%
			        		   couter++;
			        		 } %>
			        		</table>
		        		</div>
		        	</div>
	        	</form>
	        </div>    
	        
			<div id="tabs-5">
			    <div>
					<table align="right">
							<td><a href="<%="../question/create.jsp?percode="+perCode%>"><span class="ui-icon ui-icon-plus"></span></a></td>
							<td style="color:#2e6e9e;"><a href="<%="../question/create.jsp?percode="+perCode%>">เพิ่มคำถาม</a></td>
					</table>
				</div>
				
				<div>
				    <table>
					<%
					QuestionService questionService = new QuestionService();
					AnswerService answerService = new AnswerService();
					List<Question> questionLst = questionService.getList(perCode);
					for(Question q : questionLst) {
					%>
				    <tr>
				        
				    		<td>
				    		  <a href="<%="../question/edit.jsp?questionId="+q.getQuestionId()+"&percode="+perCode%>"><%=q.getQuestion()%></a>
				    		  <%=" ("+answerService.countAnswer(q.getQuestionId())+") "+sdf.format(q.getCreateDate())%>
				    		</td>
				    </tr>					
					<%} %>
					</table>
				</div>
            </div>
            
            <div id="tabs-6">
	<form action="<%=request.getContextPath()+"/SchoolEditController"%>">
	<input type="hidden" name="percode" value="<%=perCode%>"/>
	<div style="position:relative;width:250px;">
	    <div>
		<table style="position: relative;padding-top: 10px;padding-left: 5px;">
			<tr>
				<td>โรงเรียน</td>
				<%if(isEdit) { %>
				  <td><input style="color: gray;" type="text" readonly="readonly" value="<%=SchoolService.getSchoolNameByPerCode(schoolInfo.getPercodeCode())%>" name="school_name"/></td>
				<%}else { %>
				  <td><%=SchoolService.getSchoolNameByPerCode(schoolInfo.getPercodeCode())%></td>
				<%} %>
			</tr>
			<tr>
				<td>ปรัชญา</td>
				<%if(isEdit) { %>
				   <td><input type="text" name="philosophy" value="<%=StringUtil.getStringNull(schoolInfo.getPhilosophy())%>" /></td>
				<%} else { %>
				   <td><%=StringUtil.getStringNull(schoolInfo.getPhilosophy())%></td>
				<%}%>
			</tr>
			<tr>
				<td>วิสัยทัศน์</td>
				<%if(isEdit) { %>
				    <td><input type="text" name="vision" value="<%=StringUtil.getStringNull(schoolInfo.getVision())%>" /></td>
				<%} else { %>
				     <td><%=StringUtil.getStringNull(schoolInfo.getVision())%></td>
				<%} %>
			</tr>
			<tr>
				<td>พันธกิจ</td>
				<%if(isEdit) { %>
				    <td><input type="text" name="mission" value="<%=StringUtil.getStringNull(schoolInfo.getMission())%>" /></td>
				<%} else { %>
				    <td><%=StringUtil.getStringNull(schoolInfo.getMission())%></td>
				<%} %>
			</tr>	
			<tr>
				<td>ความเป็นมา</td>
				<%if(isEdit) { %>
				<td><input type="text" name="background" value="<%=StringUtil.getStringNull(schoolInfo.getBackground())%>" /></td>
				<%} else { %>
				<td><%=StringUtil.getStringNull(schoolInfo.getBackground())%></td>
				<%} %>
			</tr>
		</table>
		<%if(passLogin && !isEdit) { %>	
		  <a href="<%="listnews.jsp?percode="+perCode+"&editmode=edit#tabs-6"%>">แก้ไข</a>		  
		<%} else if(isEdit) {%>
		  <input type="submit" name="save" value="บันทึก"/>
		<%} %>
		</div>
	</div>
	</form>            
            </div>
		</div>
	</div>        
	
</div>


</body>
</html>